using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;


namespace BUS
{
 public    class tbDealBUS
    {
        public static void insert(tbDeal  deal)
        {
            tbDealDAL  dealDAL = new tbDealDAL ();
            dealDAL.Insert (deal );

        }
        public static void update(tbDeal deal)
        {
           tbDealDAL  dealDAL = new tbDealDAL ();
            dealDAL.Update (deal );

        }
     public static void Delete(int iD)
     {
         tbDealDAL  dealDAL = new tbDealDAL ();
         dealDAL.Delete(iD);
     }
        public static tbDealCollection  Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbDealDAL  dDAL = new tbDealDAL ();
            return dDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }

        public static tbDealCollection  GetALL()
        {
            int total = 0;
            tbDealDAL  dDAL = new tbDealDAL ();
            return dDAL.Get("where 1=1", 0, 0, tbDealColumn .Madeal .ToString(), "ASC", out total);
        }
        public static tbDeal  GetByID(int iD)
        {
            int total = 0;
           tbDealDAL  dDAL = new tbDealDAL ();
            tbDealCollection  dCollection = dDAL.Get("where " +
           tbDealColumn .Madeal .ToString() + "=" + iD.ToString(),
                0, 0, tbDealColumn .Madeal .ToString(), "ASC", out total);
            if (dCollection.Count > 0)
                return dCollection[0];
            return null;
        }
    }
}
